package util;
import java.util.*;

import domain.User;

public class TitleUtil {
	
	public static final int actor_bit = 1;
	public static final int director_bit = 2;
	public static final int cameraman_bit = 4;
	public static final int lighting_director_bit = 8;
	public static final int set_decorator_bit = 16;
	public static final int make_up_artist_bit = 32;
	public static final int costume_designer_bit = 64;
	public static final int props_master_bit = 128;
	
	public static List<Title> getTitles(){
		List<Title> titles=new ArrayList<Title>();
		titles.add(new Title(0,"actor","Actor/Actress" ));
		titles.add(new Title( 1,"director","Director"));
		titles.add(new Title(2,"cameraman", "Cameraman"));
		titles.add(new Title( 3,"lighting-director","Lighting Director"));
		titles.add(new Title( 4,"set-decorator","Set Decorator"));
		titles.add(new Title( 5,"make-up-artist","Make-up Artist"));
		titles.add(new Title( 6,"costume-designer","Costume Designer"));
		titles.add(new Title(7,"props-master", "Props Master"));
		
		return titles;
	}
	
	public static Map<Title,Boolean> getTitlesByUser(User user){
		Map<Title,Boolean> hasTitles=new TreeMap<Title, Boolean>();
		List<Title> titles=getTitles();
		for(Title t : titles){
			hasTitles.put(t, (user.getTitle() & t.getTitleBit()) == t.getTitleBit());
		}		
		return hasTitles;
	}
	
	public static Title getTitleByTitleName(String titleName){
		List<Title> titles=getTitles();
		for(Title title: titles){
			if(title.getTitleName().equalsIgnoreCase(titleName))
				return title;
		}
		return null;
	}
}

